﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UserControl_Security_Admin : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string userid = Convert.ToString(Request.QueryString["userid"] + "");
        if (userid != "")
        {
            string sql_checkuser = "select userid,roleid from adminuser where  flag=0 and userid='" + userid + "'";
            DataSet dset1 = null;

            DataClass.ExecuteSQL(sql_checkuser, "t1", out dset1);

            if (dset1 == null)
            {
                //lblAlert.Text = "打开数据库错误,请重试.";
                Response.Write("<script language=\"javascript\">");
                Response.Write("alert(\"打开数据库错误\");");
                Response.Write("</script>");
                return;
            }
            else
            {
                //
                if (dset1.Tables["t1"].Rows.Count > 0)
                {
                    //登陆成功
                    Session["Admin_UserID"] = dset1.Tables["t1"].Rows[0]["userid"];

                    string roleId = dset1.Tables["t1"].Rows[0]["roleid"].ToString();

                    Session["Admin_RoleID"] = roleId;
                }
                else
                {
                    //登陆失败
                    //lblAlert.Text = "登陆失败,用户名或者密码错误.";
                    Response.Write("<script language=\"javascript\">");
                    Response.Write("alert(\"登陆失败,用户名或者密码错误\");");
                    Response.Write("</script>");
                    return;
                }
            }
        }

        if (Session["Admin_UserID"] + "" == "")
        {
            
           Response.Redirect("../admin/login.aspx");
            
        }
    }

}
